//
//  NewsCell.m
//  555彩票
//
//  Created by zhoubo on 2017/7/5.
//  Copyright © 2017年 zhoubo. All rights reserved.
//

#import "NewsCell.h"

#import "UIImageView+WebCache.h"

@interface NewsCell ()

@property (nonatomic,weak) IBOutlet UIImageView* iconview;
@property (nonatomic,weak) IBOutlet UILabel* titlelabel;
@property (nonatomic,weak)IBOutlet  UILabel* digistlabel;
@property (nonatomic,weak) IBOutlet UILabel* authorlabel;

@property (nonatomic,assign) int  index;


@end

@implementation NewsCell


-(void)setNews:(News *)news
{
    _news = news;
    self.titlelabel.text = news.title;
    
    if ([news.content containsString:@"。"]) {
        self.digistlabel.text = [news.content substringToIndex:[news.content rangeOfString:@"。"].location+1];
    }
    else if ([news.content containsString:@"！"])
    {
        self.digistlabel.text = [news.content substringToIndex:[news.content rangeOfString:@"！"].location+1];
    }


    
    self.digistlabel.text = news.content;
    self.authorlabel.text = news.author ? news.author: @"蓝色大树";
    
    if (news.imgurls.count) {
        [self.iconview sd_setImageWithURL:news.imgurls[0]];
        
    }
    else
    {

        int index = arc4random_uniform(8);

        
        self.iconview.image = [UIImage imageNamed:[NSString stringWithFormat:@"00%d.jpg",index]];
        
        if (self.iconview.image == nil) {
            NSLog(@"fail to get image");
        }
    }
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
